﻿using System;
using System.Collections.Generic;

namespace Keyki.NefClass.Kernel.Data
{
    /// <summary>
    /// Class represnts one dataRow from DataSet
    /// </summary>
    public sealed class DataSample
    {
        private readonly List<double> dataRow;

        public DataSample(int capacity)
        {
            dataRow = new List<double>(capacity);
        }//DataSample

        public double this[int index]
        {
            get
            {
                if (dataRow == null)
                    throw new NullReferenceException("DataRow is null");

                if (dataRow.Count <= index)
                    throw new ArgumentOutOfRangeException();

                return dataRow[index];
            } //get
            set
            {
                if (dataRow == null)
                    throw new NullReferenceException("DataRow is null");

                if (dataRow.Count < index)
                    throw new ArgumentOutOfRangeException();

                dataRow[index] = value;
            } //set
        }//this[int]

        public int Count
        { get { return dataRow.Count; } }

        public void Add(double value)
        {
            dataRow.Add(value);
        }//Add(double)

        public void Remove(int index)
        {
            dataRow.RemoveAt(index);
        }//Remove(int)
    }//DataSample
}